<?php

namespace app\api\model;

class Banner extends BaseModel
{
    public function item()
    {
        return $this->hasMany('Banner_item','banner_id','id');
    }

    public static function getBannerById($id)
    {
        $result = self::with(['item'=>function($query){
            $query->order('id','desc');
        },'item'=>function($query){
            $query->with(['img']);
        }])->find($id);

        return $result;
    }
}
